#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 时间     : 2020-03-11 13:17:39
# 作者     : DL (584054432@qq.com)
# 网址     : https://gitee.com/dingliangPython/
# 软件版本 : Python3.7.3
# 功能     ：
import logging
from suds.client import Client

xml='''<?xml version="1.0" encoding="UTF-8"?>
<YGCT>
    <HEAD>  
        <VERSION>1.0</VERSION>
        <SRC>0500000003</SRC>
        <DES>0500000003</DES>
        <MsgNo>41110</MsgNo>
        <MsgId>201711040300024520000000000000007186</MsgId>
        <MsgRef/>
        <TransDate>20171104030002</TransDate>
        <Reserve/>
    </HEAD>
    <MSG>
        <CzpSend41110>
            <ID>38a2b471b08542e2a048ff1ab11fa6f4</ID>
            <CZPBH>2017110404001</CZPBH>
            <CZPLX>00000005</CZPLX>
            <CZPZT>00000002</CZPZT>
            <CZPJG/>
            <CZPSCMS>1</CZPSCMS>
            <CZPZXMS>1</CZPZXMS>
            <KPRY/>
            <KPSJ>20171104030000</KPSJ>
            <CZPKSSJ/>
            <CZPJSSJ/>
            <CZRY/>
            <ZYBH/>
            <YPSL>6</YPSL>
            <YCXX/>
            <CzpSend41110SubList>
                <ID>cb016231734a4dff91457bf8be96d178</ID>
                <PID>38a2b471b08542e2a048ff1ab11fa6f4</PID>
                <XUHAO>0</XUHAO>
                <YPBM>2016173084</YPBM>
                <YPRFIDBM>E2004125120C02462210302F</YPRFIDBM>
                <YPLX>00000002</YPLX>
                <WCSJ/>
                <ZHUANGTAI>0501</ZHUANGTAI>
                <YCXX/>
            </CzpSend41110SubList>
            <CzpSend41110SubList>
                <ID>32b8ecaf93234596bfb1f54a3897a414</ID>
                <PID>38a2b471b08542e2a048ff1ab11fa6f4</PID>
                <XUHAO>0</XUHAO>
                <YPBM>2016168009</YPBM>
                <YPRFIDBM>E2004125120C02400610D976</YPRFIDBM>
                <YPLX>00000002</YPLX>
                <WCSJ/>
                <ZHUANGTAI>0501</ZHUANGTAI>
                <YCXX/>
            </CzpSend41110SubList>
            <CzpSend41110SubList>
                <ID>20c1eaf9c2884a148b5df2108648fa04</ID>
                <PID>38a2b471b08542e2a048ff1ab11fa6f4</PID>
                <XUHAO>0</XUHAO>
                <YPBM>2016172032</YPBM>
                <YPRFIDBM>E2005114591901690200F80A</YPRFIDBM>
                <YPLX>00000002</YPLX>
                <WCSJ/>
                <ZHUANGTAI>0501</ZHUANGTAI>
                <YCXX/>
            </CzpSend41110SubList>
            <CzpSend41110SubList>
                <ID>d74d74fba32f486b823c088041d39b61</ID>
                <PID>38a2b471b08542e2a048ff1ab11fa6f4</PID>
                <XUHAO>0</XUHAO>
                <YPBM>2016173560</YPBM>
                <YPRFIDBM>E2004125120C02431150A551</YPRFIDBM>
                <YPLX>00000002</YPLX>
                <WCSJ/>
                <ZHUANGTAI>0501</ZHUANGTAI>
                <YCXX/>
            </CzpSend41110SubList>
            <CzpSend41110SubList>
                <ID>c842f388dd6a49bc818efa36f66de7c3</ID>
                <PID>38a2b471b08542e2a048ff1ab11fa6f4</PID>
                <XUHAO>0</XUHAO>
                <YPBM>2016168570</YPBM>
                <YPRFIDBM>E2004125120C0238219033FC</YPRFIDBM>
                <YPLX>00000002</YPLX>
                <WCSJ/>
                <ZHUANGTAI>0501</ZHUANGTAI>
                <YCXX/>
            </CzpSend41110SubList>
            <CzpSend41110SubList>
                <ID>92f682dfbb6b469b8963b9a47dbece15</ID>
                <PID>38a2b471b08542e2a048ff1ab11fa6f4</PID>
                <XUHAO>0</XUHAO>
                <YPBM>2016173352</YPBM>
                <YPRFIDBM>E2004125120C0244181059B6</YPRFIDBM>
                <YPLX>00000002</YPLX>
                <WCSJ/>
                <ZHUANGTAI>0501</ZHUANGTAI>
                <YCXX/>
            </CzpSend41110SubList>
        </CzpSend41110>
    </MSG>
</YGCT>
'''
class Wcf_Clinet(object):
    """docstring for Wcf_Clinet"""
    def __init__(self, url='http://127.0.0.1:50000/MCService'):
        super(Wcf_Clinet, self).__init__()
        self.log=logging.getLogger("main.wcf")
        self.url=url
        try:
            self.client=Client(url)
        except Exception as e:
            self.log.error("无法连接初始化WCF客户端")
    def send_mc(self,xml):
        try:
            self.client.service.ygctCicsData(xml)
            self.log.warning("发送XML到MC成功")
            return True
        except Exception as e:
            self.log.warning("发送XML到MC失败:{}".format(e))

if __name__ == '__main__':
    app=Wcf_Clinet()
    app.send_mc(xml)
  
